Koch'sche Kurve

-------------------------------------

Koch statisch
=============
ScriptBegin
var Grafik = "Script Turtle";

BackB="cadetblue"; "white"; 
Brush="lightsalmon"
Pen_mm=0.2;

l=1.14;   // Gre 0.5 - 3.5
w=75;    //89 Winkel 0-360
x0=-57;  //Ecke links oben 
y0=151;


/* Qption
l=2.0;   // Gre 0.5 - 3.5
w=85;    //89 Winkel 0-360
x0=-59;  //Ecke links oben 
y0=150;
*/


function koch(n,l)
{ if (n<1) t.move(l, 1)
  else
  { koch(n-1, l); 
    t.turn(w);
    koch(n-1, l);
    t.turn(-2*w);
    koch(n-1, l);
    t.turn(w);  
    koch(n-1, l);
  }  
} 

function stein(l)
{t.beginPolygon();
 t.moveTo(0,0);
 koch(4,l); t.turn(90);
 koch(4,l); t.turn(90); 
 koch(4,l); t.turn(90);
 koch(4,l);
 t.endPolygon();//t.moveTo(0,0);
}

function init()
{ t.setPage(x0,y0, 4);
  t.setBrush(BackB);
}

function draw()
{ //t.drawKoordSystem();
  //t.drawRaster();
 
 // Seitenlnge bestimmen
 t.setNoStyle();
 koch(4,l); d = t.lastX(); t.moveTo(0,0,2);

 // Stein ins Polygon schreiben
 stein(l,this);  t.turnTo(0);

 t.setPen("black",Pen_mm);

 for(i=-1; i<5; i++)
 {for(j=-1; j<3; j++)
   {//t.setBrush(t.rndRGB(205,53,30));
    t.setBrush(Brush);
    t.goTo(i*d,j*d);
    t.drawPolygon();
   } 
 } 
 t.rahmen();
}
ScriptEnd
-------------------------------------------
